import request from '../utils/request.js';
import request_sh from '../utils/request_sh.js';
//添加
export function getAddAction(data) {
	return request({
		url: '/getAddAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//修改
export function getEditAction(data) {
	return request({
		url: '/getEditAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//删除
export function getDeleteAction(data) {
	return request({
		url: '/DeleteAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//查询
export function getInquiryAction(data) {
	return request({
		url: '/getInquiryAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//队列添加/修改
export function setAsynChronousAdd(data) {
	return request({
		url: '/setAsynChronousAdd?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//查询带原值
export function getInquiryIDOriginal(data) {
	return request({
		url: '/getInquiryIDOriginal?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//获取用户OpenID
export function getOpenIDAction(data) {
	return request({
		url: '/getWeChatOpenIDAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//获取用户信息
export function getMemberInfoAction(data) {
	return request({
		url: '/WeChatMemberInfoAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//地址解析
export function AddressResolution(data) {
	return request({
		url: '/getAddressResolutionAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//逆地址解析
export function LocationResolution(data) {
	return request({
		url: '/getLocationResolutionAction?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}

// 模糊查询
export function getWXGoodsIdBlurred(data) {
	return request({
		url: '/WXGoodsIdBlurred?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
// json
export function getJsonInquiry(data) {
	return request({
		url: '/getJsonInquiry',
		method: 'POST',
		data,
	})
}
// Json
export function getJson(data) {
	// return request({
	// 		url:'/getJsonInquiry?grant_type=wechat_program',
	// 		method:'POST',
	// 		data,
	// 	})
	return new Promise((resolve, reject) => {
		uni.request({
			method: 'GET',
			url: data,
			header: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			success: ({
				data,
				statusCode,
				header
			}) => {
				if (header.redirect == 'REDIRECT') {
					resolve(header)
				} else {
					resolve(data)
				}
			},
			fail: (error) => {
				reject(error)
			}
		})
	})
}
// 上传图片
export function FileList(data) {
	return request({
		url: '/FileList?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}

//  众菌联采购大厅  根据表名查询所有数据 不需要登录
export function GoodsFileInquiry(data) {
	return request({
		url: '/GoodsFileInquiry',
		method: 'POST',
		data,
	})
}

//木耳行情
export function GroupMarketQuotations(data) {
	return request({
		url: '/GroupMarketQuotations',
		method: 'POST',
		data,
	})
}

export function getInquiryTourist(data) {
	return request({
		url: '/getInquiryAction?grant_type=tourist',
		method: 'POST',
		data,
	})
}
//  获取游客Code码
export function generateTouristCode(data) {
	return request({
		url: '/generateTouristCode?grant_type=tourist',
		method: 'POST',
		data,
	})
}


export function GetChengXu(data) {
	return request_sh({
		url: '/weixin/getJumpUrl',
		method: 'POST',
		data,
	})
}
// 判断当前发起请求的环境是否为小程序
// export function GetChengXu() {

// 	return new Promise((resolve, reject) => {
// 		uni.request({
// 			url: 'https://marketingservice.ediblefungus.cn/weixin/getJumpUrl',
// 			header: {
// 				'Content-Type': 'application/x-www-form-urlencoded'
// 			},
// 			method: 'POST',
// 			success: ({
// 				data,
// 				statusCode,
// 				header
// 			}) => {
// 				if (header.redirect == 'REDIRECT') {
// 					resolve(header)
// 				} else {
// 					resolve(data)
// 				}
// 			},
// 			fail: (error) => {
// 				reject(error)
// 			}
// 		})
// 	})
// }
// 生成    小程序urlLink
export function GetUrlLink(path,interval,data) {
	return request_sh({
		url: '/weixin/getURLLink?Path='+path+'&interval='+interval+"&data="+data,
		method: 'GET',
		data:{},
	})
}
// export function GetUrlLink(path,interval,data) {
// 	return new Promise((resolve, reject) => {
// 		uni.request({
// 			// url:"http://192.168.1.136:8082/weixin/getURLLink?Path=pages/index/submitOrder&User_Number="+"15912125050"+"&interval=1",
// 			url: 'https://marketingservice.ediblefungus.cn/weixin/getURLLink?Path='+path+'&interval='+interval+"&data="+data,
// 			header: {
// 				'Content-Type': 'application/x-www-form-urlencoded'
// 			},
// 			method: 'GET',
// 			success: ({
// 				data,
// 				statusCode,
// 				header
// 			}) => {
// 				if (header.redirect == 'REDIRECT') {
// 					resolve(header)
// 				} else {
// 					resolve(data)
// 				}
// 			},
// 			fail: (error) => {
// 				reject(error)
// 			}
// 		})
// 	})
// }
// 添加redis
export function RedisAdd(data) {
	return request({
		url: '/RedisAdd?grant_type=tourist',
		method: 'POST',
		data,
	})
}

export function GetRedis(data) {
	return request({
		url: '/GetRedis?grant_type=tourist',
		method: 'GET',
		data,
	})
}
// 查询redis
//查询各个省份商品
export function getGoods1All(data) {
	return request({
		url: '/getGoods1All?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}
//查询县商品
export function getGoodsCountyAll(data) {
	return request({
		url: '/getGoodsCountyAll?grant_type=wechat_program',
		method: 'POST',
		data,
	})
}


//   查询礼品卡方案信息
export function getGiftCardInfo(data) {
	return request_sh({
		url: '/GiftCard/getGiftCardInfo',
		method: 'GET',
		data,
	})
}

